package org.kfive.nova;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;

/**
 * @program: nova
 * @author: zhanwu.lzw
 * @create: 2021-12-23 23:12
 **/
public class LocalFileFlink {

    public static void main(String[] args) {

        // set up the Table API
        EnvironmentSettings settings = EnvironmentSettings.newInstance().inBatchMode().build();
        TableEnvironment tableEnv = TableEnvironment.create(settings);
        // execute a Flink SQL job and print the result locally
        tableEnv.executeSql(
            // define the aggregation
            "SELECT word, SUM(frequency) AS `count`\n"
                // read from an artificial fixed-size table with rows and columns
                + "FROM (\n"
                + "  VALUES ('Hello', 1), ('Ciao', 1), ('Hello', 2)\n"
                + ")\n"
                // name the table and its columns
                + "AS WordTable(word, frequency)\n"
                // group for aggregation
                + "GROUP BY word")
            .print();
    }
}
